package com.smartrobot.smartrobot.activity;


import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.github.siyamed.shapeimageview.CircularImageView;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.smartrobot.smartrobot.Common.Common;
import com.smartrobot.smartrobot.R;
import com.smartrobot.smartrobot.pagerHolder.PersonalPagerHolder;
import com.smartrobot.smartrobot.util.ImageLoaderApi;
import com.smartrobot.smartrobot.util.User;

/**
 * Created by Administrator on 2015/1/12.
 */
public class ShowBigQrActivity extends Activity implements View.OnClickListener{

    ImageView qrPic;
    CircularImageView bigHead;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if(savedInstanceState != null){
            throw new NullPointerException();
        }
        this.setContentView(R.layout.page_show_qicode_pic);

        qrPic = (ImageView)findViewById(R.id.qrImageView);
        bigHead = (CircularImageView)findViewById(R.id.big_head);


        if(getIntent().getStringExtra("head") != null){

            bigHead.setVisibility(View.VISIBLE);
            qrPic.setVisibility(View.GONE);
            ImageLoaderApi.initImageLoaderApi(this);
            if(!User.getInstance().getHead().contains("/storage"))
                ImageLoader.getInstance().displayImage(Common.baseUrl + User.getInstance().getHead(), bigHead, ImageLoaderApi.getOptions());
            else
            {
                Bitmap bitmap = BitmapFactory.decodeFile(User.getInstance().getHead());
                bigHead.setImageBitmap(bitmap);

            }

            bigHead.setOnClickListener(this);
        }
        else if(PersonalPagerHolder.qrBitmap != null)
        {
            qrPic.setImageBitmap(PersonalPagerHolder.qrBitmap);
            qrPic.setOnClickListener(this);
        }



    }

    @Override
    public void onClick(View view) {

        this.finish();

    }
}
